home *** CD-ROM | disk | FTP | other *** search
/ Java Programmer's Toolkit / Java Programmer's Toolkit.iso / applets / plot2d / g2d4.jav < prev    next >
Encoding:
Text File  |  1996-01-11  |  1.5 KB  |  76 lines

  1. import java.awt.*;
  2. import java.applet.*;
  3. import java.net.URL;
  4. import java.util.*;
  5.  
  6. public class g2d4 extends Applet {
  7.  
  8.       G2Dint graph;
  9.       Label title;
  10.       DataSet data1;
  11.       Axis    xaxis;
  12.       Axis    yaxis;
  13.  
  14.  
  15.  
  16.       public void init() {
  17.         int i;
  18.         int j;
  19.  
  20.         graph = new G2Dint();
  21.  
  22.         graph.setFont(new Font("TimesRoman",Font.PLAIN,16));
  23.         
  24.         title = new Label(
  25.         "Spectrum of a giant elliptical Galaxy in the Virgo cluster",
  26.         Label.CENTER);
  27.  
  28.         title.setFont(new Font("TimesRoman",Font.PLAIN,16));
  29.  
  30.         setLayout( new BorderLayout() );
  31.         add("North",  title);
  32.         add("Center", graph);
  33.  
  34.  
  35.         try {
  36.         data1 = graph.loadFile(new URL(getDocumentBase(),"elliptical.data"));
  37.         } catch (Exception e) {
  38.           System.out.println("Failed to load data file!");
  39.         }
  40.  
  41.         data1.linecolor = new Color(255,255,0);
  42.  
  43.         xaxis = graph.createXAxis();
  44.         xaxis.attachDataSet(data1);
  45.         xaxis.title = new String("Wavelength (angstroms)");
  46.         xaxis.title_color = Color.magenta;
  47.  
  48.  
  49.         yaxis = graph.createYAxis();
  50.         yaxis.attachDataSet(data1);
  51.         yaxis.title = new String("Flux");
  52.         yaxis.title_color = Color.magenta; 
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.       }
  60.  
  61.       public void paint(Graphics g) {
  62.            graph.paint(g);
  63.       }
  64.  
  65.       public void update(Graphics g) {
  66.            graph.paint(g);
  67.       }
  68.  
  69.  
  70.  
  71. }
  72.  
  73.  
  74.  
  75.  
  76.